{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_manager__company_info', 'attach', 'company_info', 'detach', 'notify', 'observer']\n",
      "<__main__.managers object at 0x0000020A33941C50>\n"
     ]
    }
   ],
   "source": [
    "from abc import ABCMeta,abstractmethod\n",
    "class observer(metaclass=ABCMeta):\n",
    "    @abstractmethod\n",
    "    def update(self,notice):\n",
    "        pass\n",
    "class Notice:\n",
    "    def __init__(self):\n",
    "        self.observer=[]\n",
    "    def attach(self,obs):\n",
    "        self.observer.append(obs)\n",
    "    def detach(self,obs):\n",
    "        obs.company_info=None\n",
    "        self.observer.remove(obs)\n",
    "    def notify(self):\n",
    "        for obj in self.observer:\n",
    "            obj.update(self)\n",
    "class manager(Notice):\n",
    "    def __init__(self,company_info=None):\n",
    "        super().__init__()\n",
    "        self.__company_info=company_info\n",
    "    @property\n",
    "    def company_info(self):\n",
    "        return self.__company_info\n",
    "    @company_info.setter\n",
    "    def company_info(self,info):\n",
    "        self.__company_info=info\n",
    "        self.notify()\n",
    "class managers(observer):\n",
    "    def __init__(self):\n",
    "        self.company_info=None\n",
    "    def update(self,noti):\n",
    "        self.company_info=noti.company_info\n",
    "notic=manager()\n",
    "alex=managers()\n",
    "wusir=managers()\n",
    "notic.attach(alex)\n",
    "notic.attach(wusir)\n",
    "\n",
    "print(dir(notic))\n",
    "\n",
    "print(alex)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
